import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { TaskStatus, TaskType } from '../../common/enums';

/**
 * Task Response DTO
 * Used for API responses to control what data is exposed in Swagger documentation
 */
export class TaskResponseDto {
  @ApiProperty({
    description: 'Unique identifier for the task',
    format: 'uuid',
    example: '123e4567-e89b-12d3-a456-426614174000',
  })
  id: string;

  @ApiProperty({
    description: 'Task title',
    maxLength: 128,
    example: 'Create monthly report',
  })
  title: string;

  @ApiPropertyOptional({
    description: 'Task description',
    example: 'Create a detailed monthly report for the marketing department',
  })
  description: string;

  @ApiProperty({
    description: 'Task type (single or global)',
    enum: TaskType,
    example: TaskType.SINGLE,
  })
  type: TaskType;

  @ApiProperty({
    description: 'Task category ID',
    format: 'uuid',
    example: '123e4567-e89b-12d3-a456-426614174000',
  })
  taskCategoryId: string;

  @ApiPropertyOptional({
    description: 'Task category name',
    example: 'Marketing',
  })
  taskCategoryName?: string;

  @ApiPropertyOptional({
    description: 'Parent task ID if this is a subtask',
    format: 'uuid',
    example: '123e4567-e89b-12d3-a456-426614174000',
  })
  parentTaskId?: string;

  @ApiPropertyOptional({
    description: 'User ID to whom the task is assigned',
    format: 'uuid',
    example: '123e4567-e89b-12d3-a456-426614174000',
  })
  assignedUserId?: string;

  @ApiPropertyOptional({
    description: 'Name of the assigned user',
    example: 'John Doe',
  })
  assignedUserName?: string;

  @ApiPropertyOptional({
    description: 'Task start date and time',
    format: 'date-time',
    example: '2025-01-01T09:00:00Z',
  })
  startTime?: Date;

  @ApiProperty({
    description: 'Task status',
    enum: TaskStatus,
    example: TaskStatus.NOT_START,
  })
  status: TaskStatus;

  @ApiPropertyOptional({
    description: 'Task due date and time',
    format: 'date-time',
    example: '2025-12-31T23:59:59Z',
  })
  dueTime?: Date;

  @ApiPropertyOptional({
    description: 'Date and time when the task was completed',
    format: 'date-time',
    example: '2025-12-31T23:59:59Z',
  })
  completedAt?: Date;

  @ApiPropertyOptional({
    description: 'Cron expression for recurring tasks',
    example: '0 9 * * 1-5',
  })
  cronExpression?: string;

  @ApiProperty({
    description: 'Date and time when the task was created',
    format: 'date-time',
    example: '2023-01-01T00:00:00Z',
  })
  createdAt: Date;

  @ApiProperty({
    description: 'Date and time when the task was last updated',
    format: 'date-time',
    example: '2023-01-02T00:00:00Z',
  })
  updatedAt: Date;

  @ApiPropertyOptional({
    description: 'Task template ID if this task is created from a template',
    format: 'uuid',
    example: '123e4567-e89b-12d3-a456-426614174000',
  })
  taskTemplateId?: string;
}
